import 'package:casdon/modules/home/data/model/unified_device_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class MyDeviceCard extends StatelessWidget {
  final UnifiedDeviceModel model;

  const MyDeviceCard({super.key, required this.model});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 172.w,
      alignment: Alignment.topLeft,
      padding: const EdgeInsets.all(12),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(12),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 6,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // 设备图片
          Image.network(
            model.icon ?? "",
            width: 40.w,
            height: 40.h,
            fit: BoxFit.contain,
          ),
          SizedBox(height: 8.h),

          // 设备名称
          Text(
            model.name,
            style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500),
            maxLines: 1, // 限制为单行
            overflow: TextOverflow.ellipsis,
          ),
          SizedBox(height: 6.h),

          // 状态
          Text(
            model.isOnline ? "在线" : "离线",
            style: TextStyle(
              fontSize: 12,
              color: model.isOnline ? Colors.green : Colors.grey,
              fontWeight: FontWeight.w400,
            ),
          ),
        ],
      ),
    );
  }
}
